package pl.edu.mimuw.irs.rcp.controller.editor.workflow.command;

import pl.edu.mimuw.irs.core.model.design.net.IRSNode;
import pl.edu.mimuw.irs.core.model.design.net.IRSNodeCopier;

public class OverwriteNodeCommand extends IRSNodeCommand {

	// *** Attributes

	private IRSNode oldNode;
	private IRSNode newNode;
	public IRSNode getOldNode() {
		return oldNode;
	}
	public IRSNode getNewNode() {
		return newNode;
	}
	
	// *** Constructors
	
	public OverwriteNodeCommand(IRSNode source, IRSNode target) {
		super(target);
		newNode = source;
		oldNode = target.getCopier().copy(IRSNodeCopier.OMMIT_NET_ASSIGNMENT);
	}
	
	// *** Methods

	@Override
	protected void performExecute() {
		getNewNode().getCopier().copyTo(getNode());
	}

	@Override
	protected void performUndo() {
		getOldNode().getCopier().copyTo(getNode());
	}
}
